﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Repositories;
using Framework.Bus;

namespace Framework.UnitOfWork
{
    public interface IUnitOfWork
      : ISql, IDisposable
    {
        IEventBus EventBus{get;}
        object DbContext { get; }
        /// <summary>
        /// Gets a <see cref="System.Boolean"/> value which indicates
        /// whether the Unit of Work supports MS-DTC.
        /// </summary>
        
        bool DTCompatible { get; }
        /// <summary>
        /// Gets a <see cref="System.Boolean"/> value which indicates
        /// whether the Unit of Work was successfully committed.
        /// </summary>
        bool Committed { get; }
        /// <summary>
        /// Commits the transaction.
        /// </summary>
        void Commit();
        /// <summary>
        /// Rollbacks the transaction.
        /// </summary>
        void Rollback();

        void RegisterUnChanged(object obj);
        void RegisterNew(object obj);
        void RegisterModified(object obj);
        void RegisterDeleted(object obj);

        IRepository<TAggregateRoot> GetRepository<TAggregateRoot>()
         where TAggregateRoot : class, IAggregateRoot, new();
    }
}
